{extend name="admin@public/basic" /}
{block name="style"}{/block}
<link rel="stylesheet" href="__STATIC__/css/admin/public.css" media="all"/>
{block name="cotent"}
<form class="layui-form" style="width:80%;">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
            <li>用户端小程序配置</li>
            <li>推广端小程序配置</li>
            <li>工程端小程序配置</li>
            <li>微信公众号配置</li>
            <li>图片配置</li>
            <li class="configModular">e签宝配置</li>
            <li class="configModular">合同模板</li>
            <li>短信配置</li>
            <li>支付配置</li>
        </ul>

        <div class="layui-tab-content ">
            <!--基本信息-->
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">应用</label>
                    <div class="layui-input-block">
                        <select name="app_sn" class="app_sn" id="app_sn" lay-filter="selectCompany">
                            {foreach $applications as $k=>$v}
                            <option value="{$v.app_sn}" {if condition="$data && $data.app_sn eq $v.app_sn" }selected{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">企业编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="company_no" class="layui-input company_no" value="{$data.company_no|default=''}" placeholder="请输入企业编号,一旦生成不能更改" {if condition="$data && $data.company_no" }disabled{/if}>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">企业名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="company_name" class="layui-input company_name" lay-verify="required" value="{$data.company_name|default=''}" placeholder="请输入企业名称">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">企业简称</label>
                    <div class="layui-input-block">
                        <input type="text" name="short_name_en" class="layui-input short_name_en" value="{$data.short_name_en|default=''}" placeholder="请输入企业英文简称,一旦生成不能更改" {if condition="$data && $data.short_name_en" }disabled{/if}>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="admin_account" class="layui-input admin_account" value="{$data.account|default=''}" placeholder="请输入总后台登陆账号，不填系统自动生成">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">初始密码</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" type="password" name="admin_password" class="layui-input admin_password" lay-verify="required" placeholder="请输入初始密码，默认123456">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">确认密码</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" type="password" name="admin_password1" class="layui-input admin_password1" lay-verify="required" placeholder="请输入确认密码">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">营业执照编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="business_license_pic" class="layui-input business_license_pic" value="{$data.business_license_pic|default=''}" placeholder="请输入营业执照编号">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">公章防伪码</label>
                    <div class="layui-input-block">
                        <input type="text" name="seal_code" class="layui-input seal_code" value="{$data.seal_code|default=''}" placeholder="请输入公章防伪码">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">企业电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="telphone" maxlength="11" class="layui-input telphone" value="{$data.telphone|default=''}" placeholder="请输入企业电话">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-block">
                        <input type="email" name="contacts" class="layui-input contacts" value="{$data.contacts|default=''}" placeholder="请输入联系人">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">联系人电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="contacts_tel" maxlength="11" class="layui-input contacts_tel" value="{$data.contacts_tel|default=''}" placeholder="请输入联系人电话">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">企业地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="company_addr" class="layui-input company_addr" value="{$data.company_addr|default=''}" placeholder="请输入企业详细地址">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入备注信息" name="remarks" class="layui-textarea remarks">{$data.remarks|default=''}</textarea>
                    </div>
                </div>

                {if !empty($data)}
                <input type="hidden" class="id" name="id" value="{$data.company_id|default=''}">
                {/if}
            </div>
            <!--用户端小程序配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">小程序名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="app_wx_name" class="layui-input wx_app_wx_name" lay-verify="required" value="{$data.wx_config.app_wx_name|default=''}" placeholder="请输入小程序名称">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">APPID</label>
                    <div class="layui-input-block">
                        <input type="text" name="appId" class="layui-input wx_appId" value="{$data.wx_config.appId|default=''}" placeholder="请输入APPID">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">AppSecret</label>
                    <div class="layui-input-block">
                        <input type="text" name="appSecret" class="layui-input wx_appSecret" value="{$data.wx_config.appSecret|default=''}" lay-verify="required" placeholder="请输入AppSecret">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">商户号</label>
                    <div class="layui-input-block">
                        <input type="text" name="mchid" class="layui-input wx_mchid" value="{$data.wx_config.mchid|default=''}" placeholder="请输入商户号">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">支付密钥</label>
                    <div class="layui-input-block">
                        <input type="text" name="pay_key" class="layui-input wx_pay_key" lay-verify="required" value="{$data.wx_config.pay_key|default=''}" placeholder="请输入支付秘钥">
                    </div>
                </div>
            </div>
            <!--推广端小程序配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">小程序名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="app_wx_name" class="layui-input spread_app_wx_name" lay-verify="required" value="{$data.spread_wx_config.app_wx_name|default=''}" placeholder="请输入小程序名称">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">APPID</label>
                    <div class="layui-input-block">
                        <input type="text" name="appId" class="layui-input spread_appId" value="{$data.spread_wx_config.appId|default=''}" placeholder="请输入APPID">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">AppSecret</label>
                    <div class="layui-input-block">
                        <input type="text" name="appSecret" class="layui-input spread_appSecret" value="{$data.spread_wx_config.appSecret|default=''}" lay-verify="required" placeholder="请输入AppSecret">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">商户号</label>
                    <div class="layui-input-block">
                        <input type="text" name="mchid" class="layui-input spread_mchid" value="{$data.spread_wx_config.mchid|default=''}" placeholder="请输入商户号">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">支付密钥</label>
                    <div class="layui-input-block">
                        <input type="text" name="pay_key" class="layui-input spread_pay_key" lay-verify="required" value="{$data.spread_wx_config.pay_key|default=''}" placeholder="请输入支付秘钥">
                    </div>
                </div>
            </div>
            <!--维修端-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">小程序名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="app_wx_name" class="layui-input engineer_app_wx_name" lay-verify="required" value="{$data.engineer_wx_config.app_wx_name|default=''}" placeholder="请输入小程序名称">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">APPID</label>
                    <div class="layui-input-block">
                        <input type="text" name="appId" class="layui-input engineer_appId" value="{$data.engineer_wx_config.appId|default=''}" placeholder="请输入APPID">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">AppSecret</label>
                    <div class="layui-input-block">
                        <input type="text" name="appSecret" class="layui-input engineer_appSecret" value="{$data.engineer_wx_config.appSecret|default=''}" lay-verify="required" placeholder="请输入AppSecret">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">商户号</label>
                    <div class="layui-input-block">
                        <input type="text" name="mchid" class="layui-input engineer_mchid" value="{$data.engineer_wx_config.mchid|default=''}" placeholder="请输入商户号">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">支付密钥</label>
                    <div class="layui-input-block">
                        <input type="text" name="pay_key" class="layui-input engineer_pay_key" lay-verify="required" value="{$data.engineer_wx_config.pay_key|default=''}" placeholder="请输入支付秘钥">
                    </div>
                </div>

                <!--                <div class="layui-form-item layui-row layui-col-xs12">-->
                <!--                    <label class="layui-form-label">LOGO</label>-->
                <!--                    <div class="layui-input-block">-->
                <!--                        <input type="text" name="logo" class="layui-input engineer_logo" lay-verify="required" placeholder="请输入">-->
                <!--                    </div>-->
                <!--                </div>-->
            </div>
            <!--公众号-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">公众号名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="app_wx_name" class="layui-input mp_app_wx_name" lay-verify="required" value="{$data.mp_config.app_wx_name|default=''}" placeholder="请输入公众号名称">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">APPID</label>
                    <div class="layui-input-block">
                        <input type="text" name="appId" class="layui-input mp_appId" value="{$data.mp_config.appId|default=''}" placeholder="请输入公众号APPID">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">AppSecret</label>
                    <div class="layui-input-block">
                        <input type="text" name="appSecret" class="layui-input mp_appSecret" value="{$data.mp_config.appSecret|default=''}" lay-verify="required" placeholder="请输入公众号AppSecret">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">商户号</label>
                    <div class="layui-input-block">
                        <input type="text" name="mchid" class="layui-input mp_mchid" value="{$data.mp_config.mchid|default=''}" placeholder="请输入商户号">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">支付密钥</label>
                    <div class="layui-input-block">
                        <input type="text" name="pay_key" class="layui-input mp_pay_key" lay-verify="required" value="{$data.mp_config.pay_key|default=''}" placeholder="请输入支付秘钥">
                    </div>
                </div>
            </div>

            <!--图片配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">小程序图片</label>
                    <div class="layui-col-md3 layui-col-xs5">
                        <input type="hidden" name="image" class="image" value="{$data.img_config.image|default=''}"/>
                        <div class="layui-upload-list thumbBox mag0 magt3">
                            <img class="layui-upload-img thumbImg" style="width: 130px;height: 60px"
                                 src="{:config('api.qi_niu_url')}{$data.img_config.image|default=''}"
                                 onerror="javascript:this.src='__STATIC__/image/admin/nopic.png'">
                            <input type="file" name="picture" id="picture" multiple="multiple"
                                   onchange="uploadFile('picture')" accept="image/jpg,image/jpeg,image/png"/>
                        </div>
                        <div class="tips">推荐尺寸:260px*120px;使用位置:工程端登录页</div>
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">后台图片</label>
                    <div class="layui-col-md3 layui-col-xs5">
                        <input type="hidden" name="admin_image" class="admin_image"
                               value="{$data.img_config.admin_image|default=''}"/>
                        <div class="layui-upload-list thumbBox mag0 magt3">
                            <img class="layui-upload-img adminImg" style="width: 100%;height: 60px"
                                 src="{:config('api.qi_niu_url')}{$data.img_config.admin_image|default=''}"
                                 onerror="javascript:this.src='__STATIC__/image/admin/nopic.png'">
                            <input type="file" name="adminImg" id="adminImg" multiple="multiple"
                                   onchange="uploadFiles('adminImg')" accept="image/jpg,image/jpeg,image/png"/>
                        </div>
                    </div>
                </div>

            </div>
            <!--e签宝配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">企业名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_name" class="layui-input esign_name" lay-verify="required"
                               value="{$data.esign_config.name|default=''}" placeholder="请输入企业名称">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">单位类型</label>
                    <div class="layui-input-block">
                        <select name="esign_organType" class="esign_organType">
                            <option value="0" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.organType eq 0" }selected{/if}>普通企业</option>
                            <option value="1" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.organType eq 1" }selected{/if}>社会团体</option>
                            <option value="2" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.organType eq 2" }selected{/if}>事业单位</option>
                            <option value="3" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.organType eq 3" }selected{/if}>民办非企业单位</option>
                            <option value="4" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.organType eq 4" }selected{/if}>党政及国家机构</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">组织机构代码号或社会信用代码号或工商注册号</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_organCode" class="layui-input esign_organCode"
                               value="{$data.esign_config.organCode|default=''}" placeholder="请输入组织机构代码号或社会信用代码号或工商注册号">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">证件类型</label>
                    <div class="layui-input-block">
                        <select name="esign_regType" class="esign_regType">
                            <option value="0" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.regType eq 0" }selected{/if}>组织机构代码号</option>
                            <option value="1" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.regType eq 1" }selected{/if}>三证合一营业执照</option>
                            <option value="2" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.regType eq 2" }selected{/if}>工商注册号</option>
                            <option value="23" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.regType eq 23" }selected{/if}>其他</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">手机</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_mobile" class="layui-input esign_mobile"
                               value="{$data.esign_config.mobile|default=''}" placeholder="请输入手机">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_email" class="layui-input esign_email"
                               value="{$data.esign_config.email|default=''}" placeholder="请输入邮箱">
                    </div>
                </div>

                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">注册类型</label>
                    <div class="layui-input-block">
                        <select name="esign_userType" class="esign_userType">
                            <option value="2" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.userType eq 2" }selected{/if}>法人</option>
                            <option value="1" {if condition="!empty($data) && !empty($data.esign_config)  && $data.esign_config.userType eq 1" }selected{/if}>代理人</option>
                            <option value="0" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.userType eq 0" }selected{/if}>不注册法人/代理人</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">代理人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_agentName" class="layui-input esign_agentName"
                               value="{$data.esign_config.agentName|default=''}" placeholder="请输入代理人姓名">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">代理人证件号</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_agentIdNo" class="layui-input esign_agentIdNo"
                               value="{$data.esign_config.agentIdNo|default=''}" placeholder="请输入代理人证件号">
                        <div style="color:red">注意：必须是真实的证件号码！</div>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">法人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_legalName" class="layui-input esign_legalName"
                               value="{$data.esign_config.legalName|default=''}" placeholder="请输入法人姓名">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">法人证件号</label>
                    <div class="layui-input-block">
                        <input type="text" name="esign_legalIdNo" class="layui-input esign_legalIdNo" value="{$data.esign_config.legalIdNo|default=''}" placeholder="请输入法人证件号">
                        <div style="color:red">注意：必须是真实的证件号码！</div>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">法人归属地</label>
                    <div class="layui-input-block">
                        <select name="esign_legalArea" class="esign_legalArea">
                            <option value="0" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.legalArea eq 0" }selected{/if}>大陆</option>
                            <!-- <option value="1" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.legalArea eq 1"}selected{/if}>香港</option>
                             <option value="2" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.legalArea eq 2"}selected{/if}>澳门</option>
                             <option value="3" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.legalArea eq 3"}selected{/if}>台湾</option>
                             <option value="4" {if condition="!empty($data) && !empty($data.esign_config) && $data.esign_config.legalArea eq 4"}selected{/if}>外籍</option>-->
                        </select>
                    </div>
                </div>
            </div>
            <!--e签宝配置-->

            <!--合同配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">新装购买合同模板</label>
                    <div class="layui-col-md3 layui-col-xs5">
                        <input type="hidden" name="admin_image1" class="admin_image1"
                               value="{$data.img_config.admin_file1|default=''}"/>
                        <div class="layui-upload-list thumbBox mag0 magt3">
                            <div class="adminImg1">{$data.img_config.admin_file1|default=''}</div>
                            <input type="file" name="adminImg1" id="adminImg1" multiple="multiple"
                                   onchange="uploadFiles1('adminImg1')"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">新装租赁合同模板</label>
                    <div class="layui-col-md3 layui-col-xs5">
                        <input type="hidden" name="admin_image2" class="admin_image2"
                               value="{$data.img_config.admin_file2|default=''}"/>
                        <div class="layui-upload-list thumbBox mag0 magt3">
                            <div class="adminImg2">{$data.img_config.admin_file2|default=''}</div>
                            <input type="file" name="adminImg2" id="adminImg2" multiple="multiple"
                                   onchange="uploadFiles2('adminImg2')"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">移机合同模板</label>
                    <div class="layui-col-md3 layui-col-xs5">
                        <input type="hidden" name="admin_image3" class="admin_image3"
                               value="{$data.img_config.admin_file3|default=''}"/>
                        <div class="layui-upload-list thumbBox mag0 magt3">
                            <div class="adminImg3">{$data.img_config.admin_file3|default=''}</div>
                            <input type="file" name="adminImg3" id="adminImg3" multiple="multiple"
                                   onchange="uploadFiles3('adminImg3')"/>
                        </div>
                    </div>
                </div>
            </div>
            <!---->
            <!--短信配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="sms_uid" class="layui-input sms_uid" lay-verify="required"
                               value="{$data.sms_config.uid|default=''}" placeholder="请输入短信账号">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="sms_passwd" class="layui-input sms_passwd" lay-verify="required"
                               value="{$data.sms_config.passwd|default=''}" placeholder="请输入短信密码">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <input type="text" name="sms_content" class="layui-input sms_content" lay-verify="required"
                               value="{$data.sms_config.content|default=''}" placeholder="请输入短信内容">
                    </div>
                </div>
            </div>
            <!---->
            <!--支付配置-->
            <div class="layui-tab-item">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">模式</label>
                    <div class="layui-input-block ">
                        <input type="radio" name="mode" value="1" title="普通商户模式" {if condition="empty($data) || ($data && $data.pay_config && $data.pay_config.mode == 1)" }checked{/if}>
                        <input type="radio" name="mode" value="2" title="服务商模式" {if condition="$data && $data.pay_config && $data.pay_config.mode == 2" }checked{/if}>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">子商户号</label>
                    <div class="layui-input-block">
                        <input type="text" name="sub_mch_id" class="layui-input sub_mch_id" lay-verify=""
                               value="{$data.pay_config.sub_mch_id|default=''}" placeholder="请输入子商户账号,服务商模式必填">
                    </div>
                </div>
            </div>
            <!---->

        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" id="addUser">确定</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
    </div>
</form>
{/block}

{block name="script"}
<script>
    var flag = false;
    layui.use('element', function () {
        var element = layui.element;
        //一些事件监听
        element.on('tab(demo)', function (data) {
            console.log(data);
        });
    });

    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;

        // 监听选择应用
        form.on('select(selectCompany)', function (data) {
            var app_sn = $(data.elem).find("option:selected").val();
            $("#app_sn").val(app_sn);

            if(app_sn=='water2018'){
                $(".configModular").hide();//隐藏合同和e签宝板块
            }else{
                $(".configModular").show();
            }
            form.render();
        });

        /**
         * 新增以及编辑后台用户
         */
        $("#addUser").click(function () {
            if (flag) {
                return false;
            }
            flag = true;
            var data = {
                id: $(".id").val(),
                company_name: $(".company_name").val(),
                company_no: $(".company_no").val(),
                short_name_en: $(".short_name_en").val(),
                app_sn: $(".app_sn").val(),
                admin_account: $(".admin_account").val(),
                admin_password: $(".admin_password").val(),
                admin_password1: $(".admin_password1").val(),
                business_license_pic: $(".business_license_pic").val(),
                seal_code: $(".seal_code").val(),
                telphone: $(".telphone").val(),
                contacts: $(".contacts").val(),
                contacts_tel: $(".contacts_tel").val(),
                company_addr: $(".company_addr").val(),
                remarks: $(".remarks").val(),
                wx_config: {
                    app_wx_name: $(".wx_app_wx_name").val(),
                    appId: $(".wx_appId").val(),
                    appSecret: $(".wx_appSecret").val(),
                    mchid: $(".wx_mchid").val(),
                    pay_key: $(".wx_pay_key").val(),
                },
                spread_wx_config: {
                    app_wx_name: $(".spread_app_wx_name").val(),
                    appId: $(".spread_appId").val(),
                    appSecret: $(".spread_appSecret").val(),
                    mchid: $(".spread_mchid").val(),
                    pay_key: $(".spread_pay_key").val(),
                },
                engineer_wx_config: {
                    app_wx_name: $(".engineer_app_wx_name").val(),
                    appId: $(".engineer_appId").val(),
                    appSecret: $(".engineer_appSecret").val(),
                    mchid: $(".engineer_mchid").val(),
                    pay_key: $(".engineer_pay_key").val(),
                },
                mp_config: {
                    app_wx_name: $(".mp_app_wx_name").val(),
                    appId: $(".mp_appId").val(),
                    appSecret: $(".mp_appSecret").val(),
                    mchid: $(".mp_mchid").val(),
                    pay_key: $(".mp_pay_key").val(),
                },
                img_config: {
                    image: $(".image").val(),
                    admin_image: $(".admin_image").val(),
                    admin_file1: $(".admin_image1").val(),
                    admin_file2: $(".admin_image2").val(),
                    admin_file3: $(".admin_image3").val(),
                },
                esign_config: {
                    name: $(".esign_name").val(),
                    organCode: $(".esign_organCode").val(),
                    regType: $(".esign_regType").val(),
                    mobile: $(".esign_mobile").val(),
                    email: $(".esign_email").val(),
                    organType: $(".esign_organType").val(),
                    userType: $(".esign_userType").val(),
                    agentName: $(".esign_agentName").val(),
                    agentIdNo: $(".esign_agentIdNo").val(),
                    legalName: $(".esign_legalName").val(),
                    legalArea: $(".esign_legalArea").val(),
                    legalIdNo: $(".esign_legalIdNo").val(),
                },
                sms_config: {
                    uid: $(".sms_uid").val(),
                    passwd: $(".sms_passwd").val(),
                    content: $(".sms_content").val(),
                },
                pay_config: {
                    mode: $('input[name="mode"]:checked').val(),
                    sub_mch_id: $(".sub_mch_id").val(),
                }
            };
            var url = '{if empty($data)}/Api/Company/add{else/}/Api/Company/edit{/if}';
            $.ajax({
                method: "POST",
                url: url,
                // url: '/Api/Company/add',
                contentType: 'application/json; charset=UTF-8',
                header: {
                    'token': "bbbb", // 默认值
                },
                dataType: 'json',
                data: JSON.stringify(data),
                success: (data) => {
                    console.log(data)
                    flag = false;
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1});
                        setTimeout(function () {
                            //刷新父页面
                            parent.location.reload();
                            // location.href='{:url("$thisClass/index")}';
                        }, 500)
                    } else {
                        layer.msg(data.msg, {icon: 2}, function () {
                            layer.close();
                        });
                    }

                },
                error: () => {
                    layer.msg('系统错误，请稍后再试', {icon: 2}, function () {
                        // tableIns.reload();
                    });
                    flag = false;
                }
            })

            return false;
        });

    })

    // 上传图片11
    function uploadFile(inputName) {
        var data = new FormData();
        $.each($('input[name="' + inputName + '"]')[0].files, function (i, file) {
            data.append('file', file);

        });
        //console.log(data.get(inputName))
        //清空图片
        $('#' + inputName).val('');
        //提交数据
        $.ajax({
            url: "{:url('api/Upload/uploadFile')}",
            type: 'POST',
            data: data,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            // dataType: 'json',
            success: function (res) {
                if (res.code == 1000) {
                    $('.thumbImg').attr('src', res.data.all_url);
                    $("input[name='image']").val(res.data.url);
                }
            },
            error: function (returndata) {
                parent.layer.msg('数据异常', {
                    icon: 2,
                    time: 2000
                });
                return false;
            }
        });
    }

    // 上传图片22
    function uploadFiles(inputName) {
        var data = new FormData();
        $.each($('input[name="' + inputName + '"]')[0].files, function (i, file) {
            data.append('file', file);

        });
        //console.log(data.get(inputName))
        //清空图片
        $('#' + inputName).val('');
        //提交数据
        $.ajax({
            url: "{:url('api/Upload/uploadFile')}",
            type: 'POST',
            data: data,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            // dataType: 'json',
            success: function (res) {
                if (res.code == 1000) {
                    $('.adminImg').attr('src', res.data.all_url);
                    $("input[name='admin_image']").val(res.data.url);
                }
            },
            error: function (returndata) {
                parent.layer.msg('数据异常', {
                    icon: 2,
                    time: 2000
                });
                return false;
            }
        });
    }

    // 上传新装购买合同模板
    function uploadFiles1(inputName) {
        var data = new FormData();
        $.each($('input[name="' + inputName + '"]')[0].files, function (i, file) {
            data.append('file', file);

        });
        //console.log(data.get(inputName))
        //清空图片
        $('#' + inputName).val('');
        //提交数据
        $.ajax({
            url: "{:url('api/Upload/uploadFile')}",
            type: 'POST',
            data: data,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            // dataType: 'json',
            success: function (res) {
                if (res.code == 1000) {
                    $('.adminImg1').html(res.data.all_url + '上传成功！');
                    $("input[name='admin_image1']").val(res.data.url);
                }
            },
            error: function (returndata) {
                parent.layer.msg('数据异常', {
                    icon: 2,
                    time: 2000
                });
                return false;
            }
        });
    }

    // 上传新装租赁合同模板
    function uploadFiles2(inputName) {
        var data = new FormData();
        $.each($('input[name="' + inputName + '"]')[0].files, function (i, file) {
            data.append('file', file);

        });
        //console.log(data.get(inputName))
        //清空图片
        $('#' + inputName).val('');
        //提交数据
        $.ajax({
            url: "{:url('api/Upload/uploadFile')}",
            type: 'POST',
            data: data,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            // dataType: 'json',
            success: function (res) {
                if (res.code == 1000) {
                    $('.adminImg2').html(res.data.all_url + '上传成功！');
                    $("input[name='admin_image2']").val(res.data.url);
                }
            },
            error: function (returndata) {
                parent.layer.msg('数据异常', {
                    icon: 2,
                    time: 2000
                });
                return false;
            }
        });
    }

    // 上传移机合同模板
    function uploadFiles3(inputName) {
        var data = new FormData();
        $.each($('input[name="' + inputName + '"]')[0].files, function (i, file) {
            data.append('file', file);

        });
        //console.log(data.get(inputName))
        //清空图片
        $('#' + inputName).val('');
        //提交数据
        $.ajax({
            url: "{:url('api/Upload/uploadFile')}",
            type: 'POST',
            data: data,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            // dataType: 'json',
            success: function (res) {
                if (res.code == 1000) {
                    $('.adminImg3').html(res.data.all_url + '上传成功！');
                    $("input[name='admin_image3']").val(res.data.url);
                }
            },
            error: function (returndata) {
                parent.layer.msg('数据异常', {
                    icon: 2,
                    time: 2000
                });
                return false;
            }
        });
    }


</script>
{/block}
